<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title>工程施工实时监控系统</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">


    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">

    <!--<link rel="stylesheet" href="${pageContext.request.contextPath}/${pageContext.request.contextPath}/${pageContext.request.contextPath}/plugins/timepicker/bootstrap-timepicker.min.css">-->

    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>


    <!--<script src="${pageContext.request.contextPath}/${pageContext.request.contextPath}/${pageContext.request.contextPath}/plugins/timepicker/bootstrap-timepicker.min.js"></script>-->

    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/iCheck/square/blue.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/morris/morris.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/datepicker/datepicker3.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.theme.default.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/select2/select2.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.skinNice.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap-slider/slider.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/layui/css/layui.css" media="all">
    <style>
        .content {
            padding-bottom: 25px;
        }

        /*使layui数据表格的checkbox居中*/
        .layui-table-cell .layui-form-checkbox[lay-skin="primary"] {
            top: 50%;
            transform: translateY(-50%);
        }

        .across {
            padding: 6px 12px;
            font-size: 14px;
            font-weight: 400;
            line-height: 1;
            color: #555;
            text-align: center;
            background-color: #eee;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
    </style>
</head>

<body class="hold-transition skin-purple sidebar-mini">

<security:authentication property="principal.id" var="id"
></security:authentication>
<div class="wrapper">
    <!-- 页面头部 -->
    <jsp:include page="header.jsp"></jsp:include>
    <!-- 页面头部 /-->

    <!-- 导航侧栏 -->
    <jsp:include page="aside.jsp"></jsp:include>
    <!-- 导航侧栏 /-->

    <!-- 内容区域 -->
    <!-- @@master = admin-layout.html-->
    <!-- @@block = content -->

    <div class="content-wrapper" <%--style="margin-left: 0px"--%>>

        <!-- 内容头部 -->
        <section class="content-header">
            <h1 id="title">
                报警信息
                <%--<small>数据列表</small>--%>
            </h1>
            <ol class="breadcrumb">
                <li><a href="${pageContext.request.contextPath}/pages/main.jsp"><i class="fa fa-dashboard"></i> 首页</a>
                </li>
                <%--<li><a href="#">数据管理</a></li>--%>
                <li class="active" id="active">报警信息</li>
            </ol>
        </section>
        <!-- 内容头部 /-->

        <!-- 正文区域 -->
        <section class="content">
            <div class="box box-primary" >
            </div>
            <div class="layui-tab layui-tab-brief" lay-filter="tabDemo">
                <ul class="layui-tab-title">
                    <li class="layui-this" lay-id="111" style="float: right">报警信息</li>
                    <li lay-id="222" style="float: right">预警信息</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">

                        <div class="demoTable" style="height: 240px">
                            <div class="layui-form layui-card-header layuiadmin-card-header-auto" id="resetForm">
                                <%--<div class="layui-form-item">--%>
                                <div class="layui-inline" style="width: 160px">
                                    <select name="template" id="template" lay-filter="template" style="width: 80px;">
                                        <option value="">---请选择模板---</option>
                                        <%--     <c:forEach items="${selectTemplates}" var="selectTemplate">
                                                 <option value="${selectTemplate.selectValue}">${selectTemplate.selectName}</option>
                                             </c:forEach>--%>
                                    </select>
                                </div>

                                <div class="layui-inline">
                                    <input class="layui-input" autocomplete="off" name="stakeMark" id="stakeMark"
                                           placeholder="请输入段落号">

                                </div>

                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" autocomplete="off" id="start" name="start"
                                           placeholder="开始日期">
                                </div>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" autocomplete="off" id="end" name="end"
                                           placeholder="结束日期">
                                </div>


                                <button class="layui-btn" data-type="reload">搜索</button>
                                <button class="layui-btn" id="reset">重置</button>
                                <button class="layui-btn" id="save">保存并查询</button>
                                <button class="layui-btn" id="add">新增模板</button>
                                <button class="layui-btn" id="del">删除模板</button>
                                <div style="margin-top: 10px;">
                                    <div class="layui-inline" style="margin-left: 36px;">
                                        <label>施工桩长(m):</label>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="pile_lengths" id="pile_lengths">
                                    </div>
                                    <div class="layui-inline">
                                        <span class="across">-</span>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="pile_lengthe" id="pile_lengthe">

                                    </div>
                                    <div class="layui-inline" style="margin-left: 40px;">
                                        <label>提升速度(cm/min)</label>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="to_drill_avs" id="to_drill_avs">
                                    </div>
                                    <div class="layui-inline">
                                        <span class="across">-</span>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="to_drill_ave" id="to_drill_ave">

                                    </div>
                                </div>
                                <div>
                                    <div class="layui-inline">
                                        <label>下钻速度(cm/min):</label>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="rih_avs" id="rih_avs">
                                    </div>
                                    <div class="layui-inline">
                                        <span class="across">-</span>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="rih_ave" id="rih_ave">

                                    </div>
                                    <div class="layui-inline" style="margin-left: 73px;">
                                        <label>最大电流(A):</label>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="maxdls" id="maxdls">
                                    </div>
                                    <div class="layui-inline">
                                        <span class="across">-</span>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="maxdle" id="maxdle">

                                    </div>
                                </div>
                                <div>
                                    <div class="layui-inline" style="margin-left: 16px;">
                                        <label>平均灰量(kg/m):</label>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="average_aols" id="average_aols">
                                    </div>
                                    <div class="layui-inline">
                                        <span class="across">-</span>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="average_aole" id="average_aole">

                                    </div>
                                    <div class="layui-inline" style="margin-left: 107px;">
                                        <label>水灰比:</label>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="water_cement_ratios"
                                               id="water_cement_ratios">
                                    </div>
                                    <div class="layui-inline">
                                        <span class="across">-</span>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="water_cement_ratioe"
                                               id="water_cement_ratioe">

                                    </div>
                                </div>
                                <div>
                                    <div class="layui-inline" style="margin-left: 41px;">
                                        <label>成桩时间(s):</label>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="pile_times" id="pile_times">
                                    </div>
                                    <div class="layui-inline">
                                        <span class="across">-</span>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="pile_time_end"
                                               id="pile_time_end">

                                    </div>
                                    <div class="layui-inline" style="margin-left: 107px;">
                                        <label>垂直度:</label>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="slopes" id="slopes">
                                    </div>
                                    <div class="layui-inline">
                                        <span class="across">-</span>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" type="number" name="slope_end" id="slope_end">

                                    </div>
                                </div>
                                <%--</div>--%>
                            </div>
                        </div>
                        <table class="layui-hide" id="test" lay-filter="test">

                        </table>

                        <script type="text/html" id="toolbarDemo">

                            <%--<button class=" layui-icon-cols" lay-event="refresh">刷新</button>--%>
                        </script>
                        <script type="text/html" id="barDemo">
                            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="asd">删除</a>
                        </script>
                    </div>
                    <div class="layui-tab-item">

                        <div class="demoTable">
                            <div class="layui-form layui-card-header layuiadmin-card-header-auto" id="formRest">
                                <security:authorize access="hasAnyRole('ROLE_SUPER_ADMIN,ROLE_ADMIN')">
                                    <div class="layui-inline">
                                        <select name="projectId" id="projectId" lay-filter="projectId">
                                            <option value="">请选择项目</option>
                                        </select>
                                    </div>
                                    <div class="layui-inline" id="sectionSel">
                                        <select name="sectionId" id="sectionId" lay-filter="sectionId">
                                            <option value="">请选择标段</option>
                                        </select>
                                    </div>
                                </security:authorize>
                                <div class="layui-inline" style="width: 130px">
                                    <select name="state" id="state">
                                        <option value="">全部状态</option>
                                        <option value="0">待处理</option>
                                        <option value="1">已处理</option>
                                        <option value="3">未通过查验</option>
                                        <option value="4">已通过查验</option>
                                        <option value="5">已驳回</option>
                                        <option value="6">已闭合</option>
                                    </select>
                                </div>


                                <div class="layui-btn" data-type="reload">搜索</div>
                                <div class="layui-btn" id="reset">重置</div>

                                <%--</div>--%>
                            </div>
                        </div>
                        <table class="layui-hide" id="earlyTable" lay-filter="earlyTable">

                        </table>
                        <script type="text/html" id="barDemo2">
                            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="asd">删除</a>
                        </script>
                        <script type="text/html" id="toolbar">

                            <%--<button class=" layui-icon-cols" lay-event="refresh">刷新</button>--%>
                        </script>
                    </div>
                </div>
            </div>

            <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
        </section>
        <!-- 正文区域 /-->

    </div>
    <!-- @@close -->
    <!-- 内容区域 /-->


</div>

<script src="${pageContext.request.contextPath}/plugins/layui/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.js"></script>
<script src="${pageContext.request.contextPath}/plugins/jQueryUI/jquery-ui.min.js"></script>
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/adminLTE/js/app.min.js"></script>
<script>
    layui.config({
        dir: '/plugins/layui/'
        , version: false
        , debug: false
        , base: ''
    });
    //主体表格
    layui.use(['table', 'layer', 'form', 'element', 'laydate'], function () {
        var table = layui.table;
        var form = layui.form;
        var element = layui.element;
        var laydate = layui.laydate;
        var id = "${id}";
        table.render({
            elem: '#test'
            , url: '/cement/findAll.do'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-refresh'
            }]
            , skin: 'nob'
            , totalRow: true
            , title: '生产记录'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                // , {field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true}

                , {field: 'stake_mark', title: '桩号', width: 140, edit: 'text'}
                , {field: 'device_code', title: '设备编号', hide: true, width: 120, edit: 'text', align: "center"}
                , {field: 'pile_driver_num', title: '桩机号', hide: true, width: 120, edit: 'text', align: "center"}
                , {
                    field: 'start_date',
                    align: "center",
                    title: '开始时间',
                    width: 165,
                    edit: 'text',
                    templet: "<div>{{layui.util.toDateString(d.start_date, 'yyyy-MM-dd HH:mm:ss')}}</div>"
                }
                , {
                    field: 'end_date',
                    align: "center",
                    title: '结束时间',
                    width: 165,
                    edit: 'text',
                    templet: "<div>{{layui.util.toDateString(d.end_date, 'yyyy-MM-dd HH:mm:ss')}}</div>"
                }

                , {field: 'pile_length', title: '施工桩长(m)', edit: 'text', align: "center"}
                , {field: 'au_aol', title: '累计灰量(kg)', width: 153, edit: 'text', align: "center"}
                , {field: 'au_aoc', title: '累计浆量(kg)', width: 153, edit: 'text', align: "center"}
                , {field: 'cjsd', title: '初搅深度', width: 120, hide: true, edit: 'text', align: "center"}

                , {field: 'fjsd', title: '复搅深度', width: 120, hide: true, edit: 'text', align: "center"}
                , {field: 'water_cement_ratio', title: '水灰比', hide: true, width: 120, edit: 'text', align: "center"}
                , {field: 'rih_av', title: '平均下钻速度', width: 120, edit: 'text', align: "center"}
                , {field: 'to_drill_av', title: '平均提钻速度', width: 120, edit: 'text', align: "center"}
                , {
                    field: 'average_aoc',
                    title: '平均浆量',
                    hide: true,
                    width: 120,
                    hide: true,
                    edit: 'text',
                    align: "center"
                }
                , {field: 'average_aol', title: '平均灰量', width: 120, edit: 'text', align: "center"}
                , {field: 'average_current', title: '平均电流', hide: true, width: 120, edit: 'text', align: "center"}
                , {field: 'zdzs', title: '最大钻速', width: 120, hide: true, edit: 'text', align: "center"}
                , {field: 'zdts', title: '最大提速', width: 120, hide: true, edit: 'text', align: "center"}
                , {field: 'zdxd', title: '最大斜度', width: 120, hide: true, edit: 'text', align: "center"}
                , {field: 'pile_time', title: '成桩时间(s)', width: 120, edit: 'text', align: "center"}
                , {field: 'kdtzc', title: '扩大头桩长', hide: true, width: 120, edit: 'text', align: "center"}
                , {field: 'kdthl', title: '扩大头灰量', hide: true, width: 120, edit: 'text', align: "center"}
                , {field: 'kdtjl', title: '扩大头浆量', hide: true, width: 120, edit: 'text', align: "center"}
                , {field: 'xbzjl', title: '下部桩浆量', hide: true, width: 120, edit: 'text', align: "center"}
                , {field: 'xbzhl', title: '下部桩灰量', hide: true, width: 120, edit: 'text', align: "center"}
                , {field: 'yjjb', title: '预警级别', hide: true, width: 120, edit: 'text', align: "center"}
                , {field: 'xxx', title: '评级', hide: true, width: 120, edit: 'text', align: "center"}
                , {field: 'empty_stir_depth', title: '空搅深度', hide: true, width: 120, edit: 'text', align: "center"}
                , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150}
            ]],
            done: function (res, curr, count) {
                // console.log(res.totalPileLength)
                //然后把值写上去td[data-field="itemNo" 定义在哪个列后显示
                this.elem.next().find('.layui-table-total td[data-field="stake_mark"] .layui-table-cell').html('<div class="layui-inline" style="width: 330px">总桩数&nbsp;&nbsp;<span style="font-size: 20px;color: #333;">'+res.totalPiles+'</span>&nbsp;&nbsp;根</div>'
                                                                                                               +'<div class="layui-inline" style="width: 330px">总桩数&nbsp;&nbsp;<span style="font-size: 20px;color: #333;">'+res.totalPiles+'</span>&nbsp;&nbsp;根</div>'
                                                                                                                +'<div class="layui-inline" style="width: 330px">总桩数&nbsp;&nbsp;<span style="font-size: 20px;color: #333;">'+res.totalPiles+'</span>&nbsp;&nbsp;根</div>'
                                                                                                                +'<div class="layui-inline" style="width: 330px">总桩数&nbsp;&nbsp;<span style="font-size: 20px;color: #333;">'+res.totalPiles+'</span>&nbsp;&nbsp;根</div>'
                                                                                                                +'<div class="layui-inline" style="width: 330px">总桩数&nbsp;&nbsp;<span style="font-size: 20px;color: #333;">'+res.totalPiles+'</span>&nbsp;&nbsp;根</div>');
                this.elem.next().find('.layui-table-total td[data-field="stake_mark"] .layui-table-cell').css({"width":"1700%"})
/*                this.elem.next().find('.layui-table-total td[data-field="pile_length"] .layui-table-cell').text(res.totalPileLength);
                this.elem.next().find('.layui-table-total td[data-field="au_aoc"] .layui-table-cell').text(res.sumAoc);
                this.elem.next().find('.layui-table-total td[data-field="au_aol"] .layui-table-cell').text(res.sumAol);*/
            }, text: {
                none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            }

            , page: true
            , id: 'testReload'
        });
        //条件查询重载表格
        var $ = layui.$, active = {
            reload: function () {
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        // key: {

                        stakeMark: $("#stakeMark").val(),
                        start: $("#start").val(),
                        end: $("#end").val(),
                        pileLength: $("#pile_lengths").val(),
                        pileLength2: $("#pile_lengthe").val(),
                        to_drill_avs: $("#to_drill_avs").val(),
                        to_drill_ave: $("#to_drill_ave").val(),
                        rih_avs: $("#rih_avs").val(),
                        rih_ave: $("#rih_ave").val(),
                        currentMax: $("#maxdls").val(),
                        currentMax2: $("#maxdle").val(),
                        aol: $("#average_aols").val(),
                        aol2: $("#average_aole").val(),
                        water_cement_ratios: $("#water_cement_ratios").val(),
                        water_cement_ratioe: $("#water_cement_ratioe").val(),
                        pileTime: $("#pile_times").val(),
                        pileTime2: $("#pile_time_end").val(),
                        slopes: $("#slopes").val(),
                        slope_end: $("#slope_end").val()
                        // }
                    }
                }, 'data');
            }
        };
        //监听tab切换
        element.on('tab(tabDemo)', function (data) {
            /*            console.log($(this).text()); //当前Tab标题所在的原始DOM元素
                        console.log(data.index); //得到当前Tab的所在下标
                           console.log(data.elem); //得到当前的Tab大容器*/
            $("#title").html($(this).text());
            $("#active").html($(this).text());
        });
        //日期时间选择器
        laydate.render({
            elem: '#start'
            , type: 'datetime'
        });
        laydate.render({
            elem: '#end'
            , type: 'datetime'
        });

        //重置按钮
        $('#reset').on('click', function () {
            $(':input', '#resetForm')
                .not(":button", ":reset", "hidden", "submit")
                .val("")
                .removeAttr("checked")
                .removeAttr("selected");
            //执行重载
            table.reload('testReload', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , where: {
                    stakeMark: $("#stakeMark").val(),
                    start: $("#start").val(),
                    end: $("#end").val(),
                    pileLength: $("#pile_lengths").val(),
                    pileLength2: $("#pile_lengthe").val(),
                    to_drill_avs: $("#to_drill_avs").val(),
                    to_drill_ave: $("#to_drill_ave").val(),
                    rih_avs: $("#rih_avs").val(),
                    rih_ave: $("#rih_ave").val(),
                    maxdls: $("#maxdls").val(),
                    maxdle: $("#maxdle").val(),
                    average_aols: $("#average_aols").val(),
                    average_aole: $("#average_aole").val(),
                    water_cement_ratios: $("#water_cement_ratios").val(),
                    water_cement_ratioe: $("#water_cement_ratioe").val(),
                    pile_times: $("#pile_times").val(),
                    pile_time_end: $("#pile_time_end").val(),
                    slopes: $("#slopes").val(),
                    slope_end: $("#slope_end").val()
                }//设置需要重新请求的参数
            }, 'data');
        });


        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        //头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                /* case 'refresh':
                     $(".layui-laypage-btn").click();
                     layer.msg('刷新');

                     break;*/
                //自定义头工具栏右侧图标 - 提示
                case 'LAYTABLE_TIPS':
                    $(".layui-laypage-btn").click();
                    break;
            }
        });

        //select下拉框获取数据
        $.get("/template/findAllTemplate.do", {id: id}, function (data) {
            var carbrand = $("#template"); //这里是<select>标签的id
            var opj = "";
            for (var i = 0; i < data.length; i++) {
                // confirm(data[i])
                opj += "<option value='" + data[i].selectValue + "'>" + data[i].selectName + "</option>"
            }
            carbrand.append(opj);
            //刷新资源
            form.render('select');
        });
        //lyaui绑定下拉框事件
        form.on('select(template)', function (data) {
            var val = data.value;
            $.ajaxSetup({async: false});
            $.get("/template/findOneTemplate.do", {selectValue: val, userId: id}, function (data) {
                // console.log(data)
                if (data) {
                    $("#stakeMark").val(data.stakeMark);
                    $("#pile_lengths").val(data.pileLength);
                    $("#pile_lengthe").val(data.pileLength2);
                    $("#to_drill_avs").val(data.to_drill_avs);
                    $("#to_drill_ave").val(data.to_drill_ave);
                    $("#rih_avs").val(data.rih_avs);
                    $("#rih_ave").val(data.rih_ave);
                    $("#maxdls").val(data.maxdls);
                    $("#maxdle").val(data.maxdle);
                    $("#average_aols").val(data.average_aols);
                    $("#average_aole").val(data.average_aole);
                    $("#water_cement_ratios").val(data.water_cement_ratios);
                    $("#water_cement_ratioe").val(data.water_cement_ratioe);
                    $("#pile_times").val(data.pile_times);
                    $("#pile_time_end").val(data.pile_time_end);
                    $("#slopes").val(data.slopes);
                    $("#slope_end").val(data.slope_end);
                    // obj=data;
                    //刷新资源
                    form.render('select');
                }
            });
            //执行重载
            table.reload('testReload', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , where: {
                    stakeMark: $("#stakeMark").val(),
                    start: $("#start").val(),
                    end: $("#end").val(),
                    pileLength: $("#pile_lengths").val(),
                    pileLength2: $("#pile_lengthe").val(),
                    to_drill_avs: $("#to_drill_avs").val(),
                    to_drill_ave: $("#to_drill_ave").val(),
                    rih_avs: $("#rih_avs").val(),
                    rih_ave: $("#rih_ave").val(),
                    maxdls: $("#maxdls").val(),
                    maxdle: $("#maxdle").val(),
                    average_aols: $("#average_aols").val(),
                    average_aole: $("#average_aole").val(),
                    water_cement_ratios: $("#water_cement_ratios").val(),
                    water_cement_ratioe: $("#water_cement_ratioe").val(),
                    pile_times: $("#pile_times").val(),
                    pile_time_end: $("#pile_time_end").val(),
                    slopes: $("#slopes").val(),
                    slope_end: $("#slope_end").val()
                }
            }, 'data');
        });

        //保存按钮绑定单击事件
        $("#save").click(function () {
            //获取选中的select下拉框的value值
            $.ajaxSetup({async: false});
            $.ajax("/template/updateTemplate.do", {
                type: "GET",//请求方式
                dataType: "json",//返回参数的类型
                data: {
                    selectValue: $('#template option:selected').val(),
                    stakeMark: $("#stakeMark").val(),
                    start: $("#start").val(),
                    end: $("#end").val(),
                    pileLength: $("#pile_lengths").val(),
                    pileLength2: $("#pile_lengthe").val(),
                    to_drill_avs: $("#to_drill_avs").val(),
                    to_drill_ave: $("#to_drill_ave").val(),
                    rih_avs: $("#rih_avs").val(),
                    rih_ave: $("#rih_ave").val(),
                    maxdls: $("#maxdls").val(),
                    maxdle: $("#maxdle").val(),
                    average_aols: $("#average_aols").val(),
                    average_aole: $("#average_aole").val(),
                    water_cement_ratios: $("#water_cement_ratios").val(),
                    water_cement_ratioe: $("#water_cement_ratioe").val(),
                    pile_times: $("#pile_times").val(),
                    pile_time_end: $("#pile_time_end").val(),
                    slopes: $("#slopes").val(),
                    slope_end: $("#slope_end").val(),
                    userId: id
                },
                //contentType:"utf-8",发送请求的编码方式
                success: function (data) {//请函求成功后调用的数
                    layer.msg("保存成功")
                },
                error: function (textStatus) {//请求失败后调用的函数
                    layer.msg('保存失败');
                }
            });
            //执行重载
            table.reload('testReload', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , where: {
                    stakeMark: $("#stakeMark").val(),
                    start: $("#start").val(),
                    end: $("#end").val(),
                    pileLength: $("#pile_lengths").val(),
                    pileLength2: $("#pile_lengthe").val(),
                    to_drill_avs: $("#to_drill_avs").val(),
                    to_drill_ave: $("#to_drill_ave").val(),
                    rih_avs: $("#rih_avs").val(),
                    rih_ave: $("#rih_ave").val(),
                    maxdls: $("#maxdls").val(),
                    maxdle: $("#maxdle").val(),
                    average_aols: $("#average_aols").val(),
                    average_aole: $("#average_aole").val(),
                    water_cement_ratios: $("#water_cement_ratios").val(),
                    water_cement_ratioe: $("#water_cement_ratioe").val(),
                    pile_times: $("#pile_times").val(),
                    pile_time_end: $("#pile_time_end").val(),
                    slopes: $("#slopes").val(),
                    slope_end: $("#slope_end").val()
                }
            }, 'data');
        });
        //新增模板
        $("#add").click(function () {
            var lastVal = getVal();
            layer.open({
                type: 1
                ,
                title: '新增模板'
                ,
                offset: '100px' //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                ,
                area: ['400px', '150px']
                ,
                id: 'layerDemo' + 1 //防止重复弹出
                ,
                content: '<input type="text" id="addName" class="layui-input" placeholder="请输入模板名称"  style="width: 328px;margin-left: 36px;margin-top:10px"></input>'
                ,
                btn: '确定'
                ,
                btnAlign: 'c' //按钮居中
                ,
                shade: 0 //不显示遮罩
                ,
                yes: function (index, layero) {
                    $.ajax("/template/addTemplate.do", {
                        type: "GET",//请求方式
                        dataType: "json",//返回参数的类型
                        data: {
                            selectValue: parseInt(lastVal) + 1,
                            selectName: $("#addName").val(),
                            stakeMark: $("#stakeMark").val(),
                            start: $("#start").val(),
                            end: $("#end").val(),
                            pileLength: $("#pile_lengths").val(),
                            pileLength2: $("#pile_lengthe").val(),
                            to_drill_avs: $("#to_drill_avs").val(),
                            to_drill_ave: $("#to_drill_ave").val(),
                            rih_avs: $("#rih_avs").val(),
                            rih_ave: $("#rih_ave").val(),
                            maxdls: $("#maxdls").val(),
                            maxdle: $("#maxdle").val(),
                            average_aols: $("#average_aols").val(),
                            average_aole: $("#average_aole").val(),
                            water_cement_ratios: $("#water_cement_ratios").val(),
                            water_cement_ratioe: $("#water_cement_ratioe").val(),
                            pile_times: $("#pile_times").val(),
                            pile_time_end: $("#pile_time_end").val(),
                            slopes: $("#slopes").val(),
                            slope_end: $("#slope_end").val(),
                            userId: id
                        },
                        //contentType:"utf-8",发送请求的编码方式
                        success: function (data) {//请求成功后调用的函数
                            if (data > 0) {
                                layer.alert("添加成功", {icon: 1, title: '提示'}, function (i) {
                                    layer.close(i);
                                    layer.close(index);//关闭弹出层
                                    form.render('select');
                                    location.reload();
                                })
                                /*  $("#template").append("<option value='" + val + "'>" + addName + "</option>")
                                  $("#template").find("option[value=" + val + "]").attr("selected", true);
                                  flag = true;
                                  layer.closeAll();*/
                            } else {
                                layer.alert("修改失败", {icon: 1, title: '提示'}, function (i) {
                                    layer.close(i);
                                    layer.close(index);//关闭弹出层
                                })
                            }
                        },
                        error: function (textStatus) {//请求失败后调用的函数
                            layer.alert("服务器错误", {icon: 1, title: '提示'}, function (i) {
                                layer.close(i);
                                layer.close(index);//关闭弹出层
                            })
                        }
                    });
                    // layer.closeAll();
                }/*, end: function () {                   //请求回调，窗口销毁时执行
                                                        // window.location.href='/user/pageAll';
                    if (flag) {
                        layer.msg("添加模板成功")
                        form.render('select');
                        setTimeout(function () {
                            //1、先得到当前iframe层（弹出层）的索引  ///2、提交成功关闭弹出层窗口
                            location.reload();                 // 窗口销毁时刷新主页面数据
                        }, 1 * 1000);
                    }
                }*/
            });
        });
        //删除模板
        $("#del").click(function () {
            $.ajax("/template/deleteTemplate.do", {
                type: "GET",//请求方式
                dataType: "json",//返回参数的类型
                data: {
                    selectValue: $('#template option:selected').val(),
                    userId: id
                },
                //contentType:"utf-8",发送请求的编码方式
                success: function (data) {//请求成功后调用的函数
                    console.log(data)
                    if (data > 0) {
                        $('#template option:selected').remove();
                        // $('#template option:eq(1)').attr('selected','selected');
                        //更新渲染
                        form.render('select');
                        //删除模板成功后重置input输入框
                        $(':input', '#resetForm')
                            .not(":button", ":reset", "hidden", "submit")
                            .val("")
                            .removeAttr("checked")
                            .removeAttr("selected");
                        layer.msg("删除模板成功")
                    } else {
                        layer.msg('删除模板失败');
                    }
                },
                error: function (textStatus) {//请求失败后调用的函数
                    layer.msg('删除模板失败');
                }
            });
            //执行重载
            table.reload('testReload', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , where: {
                    stakeMark: "",
                    start: "",
                    end: "",
                    pileLength: "",
                    pileLength2: "",
                    to_drill_avs: "",
                    to_drill_ave: "",
                    rih_avs: "",
                    rih_ave: "",
                    maxdls: "",
                    maxdle: "",
                    average_aols: "",
                    average_aole: "",
                    water_cement_ratios: "",
                    water_cement_ratioe: "",
                    pile_times: "",
                    pile_time_end: "",
                    slopes: "",
                    slope_end: ""
                }
            }, 'data');
        })
        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            if (obj.event === 'asd') {
                /* layer.confirm('真的删除行么', function (index) {
                     obj.del();
                     layer.close(index);
                 });*/
                layer.open({
                    type: 2,
                    content: 'http://sentsin.com' //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                });
            } else if (obj.event === 'edit') {
                layer.open({
                    type: 2,
                    title: '详细信息',
                    maxmin: true,
                    skin: 'layui-layer-lan',
                    shadeClose: true, //点击遮罩关闭层
                    area: ['1400px', '800px'],
                    content: 'details.jsp', //弹框显示的url,对应的页面
                    btn: ['综合版', '详细版']
                    , yes: function (index, layero) {
                        //按钮【按钮一】的回调
                        // layer.msg('hello');
                        //下载报表
                        //获取当前行的id
                        var id = data.id;
                        location.href = "${pageContext.request.contextPath}/data/excel/export.do";
                    }, btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        layer.msg('hello');

                        return false;

                        //开启该代码可禁止点击该按钮关闭
                    },
                    success: function (layero, index) {
                        var iframe = window['layui-layer-iframe' + index];
                        iframe.child(data, index);
                    }
                });
            }
        });
    });

    layui.use(['table', 'layer', 'form', 'element', 'laydate'], function () {
        var $ = layui.$
        var table = layui.table;
        var form = layui.form;
        var element = layui.element;
        var laydate = layui.laydate;
        var id = "${id}";
        table.render({
            elem: '#earlyTable'
            , url: '/cement/findAll2.do'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['exports', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'refresh'
                , icon: 'layui-icon-refresh'
            }]
            , skin: 'nob'
            , totalRow: true
            , title: '预警信息'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                // , {field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true}
                , {field: 'device_code', title: '作业标识', hide: true, width: '12%', edit: 'text', align: "center"}
                , {field: 'device_code2', title: '报警项', hide: true, width: '12%', edit: 'text', align: "center"}
                , {field: 'device_code3', title: '报警值', hide: true, width: '12%', edit: 'text', align: "center"}
                , {field: 'device_code4', title: '阈值范围', hide: true, width: '12%', edit: 'text', align: "center"}
                , {field: 'device_code5', title: '报警时间', hide: true, width: '12%', edit: 'text', align: "center"}
                , {field: 'device_code6', title: '处理人', hide: true, width: '12%', edit: 'text', align: "center"}
                , {field: 'device_code7', title: '闭合人', hide: true, width: '12%', edit: 'text', align: "center"}
                , {field: 'device_code8', title: '状态', hide: true, width: '12%', edit: 'text', align: "center"}
                , {fixed: 'right', title: '操作', toolbar: '#barDemo2', width: '12%'}

            ]],
            done: function (res, curr, count) {
                $("table").css("width", "100%");

                // console.log(res.totalPileLength)
                //然后把值写上去td[data-field="itemNo" 定义在哪个列后显示
            }, text: {
                none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            }
            , page:
                true
            , id:
                'earlyTableReload'
        })
        ;
        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        }); //条件查询重载表格
        var $ = layui.$, active = {
            reload: function () {
                //执行重载
                table.reload('earlyTableReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {}
                }, 'data');
            }
        };
        //头工具栏事件
        table.on('toolbar(earlyTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                //自定义头工具栏右侧图标 - 提示
                case 'refresh':
                    $(".layui-laypage-btn").click();
                    break;
            }
        });

    });
    $(function () {
        // var a = .html()

        console.log();
    })

    function getVal() {
        var last = $("#template option:last-child").val();
        if (last == "") {
            return 0;
        }
        return last;
    }


    /*   $(document).ready(function () {
          // 选择框
          // $(".select2").select2();

          // WYSIHTML5编        /*  $(".textarea").wysihtml5({
              locale: 'zh-CN'
          });
      });*/


    /*
        // 设置激活菜单
        function setSidebarActive(tagUri) {
            var liObj = $("#" + tagUri);
            if (liObj.length > 0) {
                liObj.parent().parent().addClass("active");
                liObj.addClass("active");
            }
        }*/


    /*     $(document).ready(function () {

            // 激活导航位置
            setSidebarActive("admin-datalist");

         // 列表按钮
    /*        $("#dataList td input[type='checkbox']").iCheck({
                checkboxClass: 'icheckbox_square-blue',
                increaseArea: '20%'
            });
            // 全选操作
            $("#selall").click(function () {
                var clicks = $(this).is(':checked');
                if (!clicks) {
                    $("#dataList td input[type='checkbox']").iCheck("uncheck");
                } else {
                    $("#dataList td input[type='checkbox']").iCheck("check");
                }
                $(this).data("clicks", !clicks);
            });
        });*/

</script>
</body>

</html>
